cap log close
log using "Z:\Angrist Work\Web Papers\Angrist_1993\Angrist1993_Table6.log", replace

****************************************
* PROGRAM: Angrist1993_Table6
* PROGRAMMER: Simone Schaner
* PURPOSE: Recreates Table 6 of Angrist
*	(1993)
* DATE CREATED: 8/6/07
* NOTES: 
****************************************

clear
set mem 50m
set more off

cd "Z:\Angrist Work\Web Papers\Angrist_1993"

use soviii_ang93b

* MAKE EXTRACT -- THIS PART OF CODE IS THE SAME AS THE CODE FOR TABLE 1

g byte vietnam= q4c8==1
g byte earlyavf= q4c9==1

g byte age= (agerec==2)*22 + (agerec==3)*27 + (agerec==4)*32 + ///
	(agerec==5)*37 + (agerec==6)*42 + (agerec==7)*47 + ///
	(agerec==8)*52 + (agerec==9)*57 + (agerec==10)*62 + ///
	(agerec==11)*67
replace age=. if agerec<2 | agerec>11	

g yrsrv= (q13c<=2)*1.75 + (q13c==3)*4 + (q13c==4)*8 + (q13c>=5)*13

g oldyrsrv= (q13c==2)*1.75 + (q13c==3)*4 + (q13c==4)*8 + (q13c==5)*13
	replace oldyrsrv=. if q13c<2 | q13c>5

g byte female= sex==2

g entgrade= (q15a==1)*0 + (q15a==2)*8 + (q15a==3)*9 + ///
	(q15a==4)*10 + (q15a==5)*11 + (q15a==6)*12 + ///
	(q15a==7)*13 + (q15a==8)*13 + (q15a==9)*14 + ///
	(q15a==10)*15 + (q15a==11)*16 + (q15a==12)*17 + ///
	(q15a==13)*18 + (q15a>13)*-99
		replace entgrade=20 if q15b==4
		replace entgrade=0 if entgrade<0

g curgrade= (q15c==1)*0 + (q15c==2)*8 + (q15c==3)*9 + ///
	(q15c==4)*10 + (q15c==5)*11 + (q15c==6)*12 + ///
	(q15c==7)*13 + (q15c==8)*13 + (q15c==9)*14 + ///
	(q15c==10)*15 + (q15c==11)*16 + (q15c==12)*17 + ///
	(q15c==13)*18 + (q15c>13)*-99
		replace curgrade=20 if q15d==4
		replace curgrade=0 if curgrade<0

g eddif= curgrade-entgrade

g byte drafted= q10==1
g byte officer= q12==1 | q12==2
g size=cenplsz
g byte curmar= q14a==1
g byte entmar= q14b==1
g byte entvoc= q15a==7
g byte curvoc= q15c==7

g byte health= q22c==1
g byte nonwhite= racerec>1
g byte hispanic= q3b==1
g byte knowgi= q31_3==1
g byte vcomp= q35f==1
g vcompamt= q35g*(q35g<12)
g disper= q35j*(q35j<12)
g byte usevoc= q38a==1
g byte newed= q39a==1
g byte anyaid= q39d==1
g byte anyfed= q39e1==1 | q39e2==1 | q39e3==1

g byte gibill= q39e5==1
g byte veap= q39e6==1
g byte otherva= q39e7==1 | q39e8==1
g byte anyva= gibill | veap | otherva

g byte inelig= q39f==1

g spoused= (q46a==1)*0 + (q46a==2)*8 + (q46a==3)*9 + ///
	(q46a==4)*10 + (q46a==5)*11 + (q46a==6)*12 + ///
	(q46a==7)*13 + (q46a==8)*13 + (q46a==9)*14 + ///
	(q46a==10)*15 + (q46a==11)*16 + (q46a==12)*17 + ///
	(q46a==13)*18 + (q46a>13)*-99
		replace spoused=20 if q46b5==1
		replace spoused=0 if spoused<0

g byte spsvoc= q46a==7

g byte spswork= q46c==1 | q46c==1
g byte fulltime= q47a==1
g byte parttime= q47a==2
g byte unem= q47a==3
g byte outlf= q47a==3 | q47a>5

g earn86= q59a
	g lnearn= ln(earn86)
g self86= q59b
	g lnself= ln(self86)
g spsern86= q64a
g spself86= q64b

g numdep= q68a
g byte depchild= q70a==1

g mardif= curmar-entmar

g byte hs= q39b1
g byte coll_grad= q39b2==1 | q39b3==1
g byte corresp= q39b7==1
g byte voc_tech= q39b4==1
g byte ojt_appren= q39b5==1 | q39b6==1
g byte oth_train = q39b8==1 | q39b9==1 | q39b10==1 | q39b11==1
g byte nviet= vietnam==0
g byte white= nonwhite==0
* SELECTION CRITERIA

keep if entgrade>8 & entgrade<=16
keep if eddif>=0 & (vietnam==1 | earlyavf==1)
keep if age>=27 & age<=52
keep if yrsrv!=.

keep vetwgt age agerec pser_02 pser_07 pser_08 vietnam-white

* VARIABLES FOR REGRESSION
g hsgrad= entgrade==12
g coll= entgrade>12
g edu=1 if hsgrad
	replace edu=2 if coll
	replace edu=0 if edu==.

g vieths= vietnam*hsgrad
g vietcoll= vietnam*coll

foreach yval in 27 32 37 42 47 52 {
	g aged`yval'= age==`yval'
	g vieths`yval'= vieths*(age==`yval')
	g vietcoll`yval'= vietcoll*(age==`yval')
	}
	
replace yrsrv=2 if yrsrv==1.75

foreach val in 0 2 4 8 13 {
	g yrsrv`val'= yrsrv==`val'
	g vieths`val'= vieths*(yrsrv==`val')
	g vietcoll`val'= vietcoll*(yrsrv==`val')
	}
	
g viethsf= vieths*female
g vietcollf= vietcoll*female

* COLUMN 1
ivreg eddif female nonwhite mardif officer drafted vietnam hsgrad coll aged27 aged32 aged37 aged42 ///
	aged47 yrsrv4 yrsrv8 yrsrv13  ///
	(anyva= vieths vietcoll viethsf vietcollf vieths32 vieths37 vieths42 vieths47 vieths52 ///
			vietcoll32 vietcoll37 vietcoll42 vietcoll47 vietcoll52) 
	
* COLUMN 2
ivreg eddif female nonwhite mardif officer drafted vietnam hsgrad coll aged27 aged32 aged37 aged42 ///
	aged47 yrsrv4 yrsrv8 yrsrv13  ///
	(anyva= vieths vietcoll viethsf vietcollf vieths27 vieths32 vieths37 vieths42 vieths47 ///
	vietcoll27 vietcoll32 vietcoll37 vietcoll42 vietcoll47 vieths4 vieths8 vieths13 /// 
	vietcoll4 vietcoll8 vietcoll13) 

* COLUMN 3
ivreg eddif nonwhite mardif officer drafted vietnam hsgrad coll aged27 aged32 aged37 aged42 ///
	aged47 yrsrv4 yrsrv8 yrsrv13  ///
	(anyva= vieths vietcoll viethsf vietcollf vieths27 vieths32 vieths37 vieths42 vieths47 ///
	vietcoll27 vietcoll32 vietcoll37 vietcoll42 vietcoll47) if female==0 & oldyrsrv!=.
	
* COLUMN 4
ivreg eddif nonwhite mardif officer drafted vietnam hsgrad coll aged27 aged32 aged37 aged42 ///
	aged47 yrsrv4 yrsrv8 yrsrv13  ///
	(anyva= vieths vietcoll viethsf vietcollf vieths27 vieths32 vieths37 vieths42 vieths47 ///
	vietcoll27 vietcoll32 vietcoll37 vietcoll42 vietcoll47 vieths4 vieths8 vieths13 /// 
	vietcoll4 vietcoll8 vietcoll13) if female==0 & oldyrsrv!=.

log close